package com.ruoyi.backStage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.backStage.domain.OrderAmountCalculation;
import com.ruoyi.backStage.service.IOrderAmountCalculationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单金额计算管理Controller
 * 
 * @author xingxing
 * @date 2023-07-04
 */
@RestController
@RequestMapping("/backStage/orderAmountCalculation")
public class OrderAmountCalculationController extends BaseController
{
    @Autowired
    private IOrderAmountCalculationService orderAmountCalculationService;

    /**
     * 查询订单金额计算管理列表
     */
    @PreAuthorize("@ss.hasPermi('backStage:orderAmountCalculation:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderAmountCalculation orderAmountCalculation)
    {
        startPage();
        List<OrderAmountCalculation> list = orderAmountCalculationService.selectOrderAmountCalculationList(orderAmountCalculation);
        return getDataTable(list);
    }

    /**
     * 导出订单金额计算管理列表
     */
    @PreAuthorize("@ss.hasPermi('backStage:orderAmountCalculation:export')")
    @Log(title = "订单金额计算管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderAmountCalculation orderAmountCalculation)
    {
        List<OrderAmountCalculation> list = orderAmountCalculationService.selectOrderAmountCalculationList(orderAmountCalculation);
        ExcelUtil<OrderAmountCalculation> util = new ExcelUtil<OrderAmountCalculation>(OrderAmountCalculation.class);
        util.exportExcel(response, list, "订单金额计算管理数据");
    }

    /**
     * 获取订单金额计算管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('backStage:orderAmountCalculation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(orderAmountCalculationService.selectOrderAmountCalculationById(id));
    }

    /**
     * 新增订单金额计算管理
     */
    @PreAuthorize("@ss.hasPermi('backStage:orderAmountCalculation:add')")
    @Log(title = "订单金额计算管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderAmountCalculation orderAmountCalculation)
    {
        return toAjax(orderAmountCalculationService.insertOrderAmountCalculation(orderAmountCalculation));
    }

    /**
     * 修改订单金额计算管理
     */
    @PreAuthorize("@ss.hasPermi('backStage:orderAmountCalculation:edit')")
    @Log(title = "订单金额计算管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderAmountCalculation orderAmountCalculation)
    {
        return toAjax(orderAmountCalculationService.updateOrderAmountCalculation(orderAmountCalculation));
    }

    /**
     * 删除订单金额计算管理
     */
    @PreAuthorize("@ss.hasPermi('backStage:orderAmountCalculation:remove')")
    @Log(title = "订单金额计算管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderAmountCalculationService.deleteOrderAmountCalculationByIds(ids));
    }
}
